package com.wanxi.controller;

import com.wanxi.model.Message;
import com.wanxi.model.Team;
import com.wanxi.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/team")
public class TeamController {
    @Autowired
    TeamService teamService;

    @GetMapping("getAllTeam")
    public List<Team> getAllTeam(){
        return teamService.getAllTeam();
    }
    @GetMapping("/getTeamList")
    public Message<Team> getTeamList(@RequestParam Map map){
        return teamService.getTeamList(map);
    }
    @PostMapping("/addTeam")
    public int addTeam(Team team){
        return teamService.addTeam(team);
    }
    @GetMapping("/getTeamByCode")
    public Message getTeamByCode(String code){
        return teamService.getTeamByCode(code);
    }
    @GetMapping("/getTeamByLeader")
    public Message getTeamByLeader(@RequestParam String leader){
        return teamService.getTeamByLeader(leader);
    }
    @PostMapping("/editTeam")
    public int editTeam(@RequestParam Map map){
        return teamService.editTeam(map);
    }
    @PostMapping("/deleteTeam")
    public int deleteTeam(Integer id){
        return teamService.deleteTeam(id);
    }
    @PostMapping("/freshTeamCrew")
    public void freshTeamCrew(String code){
        teamService.freshTeamCrew(code);
    }
}
